package com.hx.ui;

import java.util.Iterator;
import java.util.Vector;

import com.hx.cmd.CommandCenter;
import com.hx.shape.Shape;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ImageView;

public class CanvasView extends ImageView{
	public CanvasView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.setBackgroundColor(Color.argb(128, 255, 255, 255));
	}
	public CanvasView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		this.setBackgroundColor(Color.argb(128, 255, 255, 255));
	}
	public CanvasView(Context context) {
		super(context);
		this.setBackgroundColor(Color.argb(128, 255, 255, 255));
	}
	public void onDraw(Canvas canvas){
		super.onDraw(canvas);
		Paint paint = new Paint();
		paint.setColor(Color.argb(128,255,0,0));
		
		Shape curShape = CommandCenter.getInstance().getCurShape();
		Vector<Shape> shapeList = CommandCenter.getInstance().getShapeList();
		
		Iterator<Shape> itr = shapeList.iterator();
		while(itr.hasNext()){
			Shape s = itr.next();
			s.paint(canvas, paint);
		}
		if(curShape!=null)
			curShape.paint(canvas, paint);
	}
}













